package com.chen.controller;

import com.chen.entity.UserInfo;
import com.chen.vo.ResultVo;
import org.springframework.web.bind.annotation.GetMapping;

public class ExceptionController {
    @GetMapping("/test1")
    public ResultVo test1() {
        UserInfo userInfo = null;
        userInfo.setUserName("zhangsan");
        return new ResultVo(500,null,userInfo);
    }

    @GetMapping("/test2")
    public ResultVo test2() {
        int[] arr= {1,2,3};
        System.out.println(arr[3]);//发生越界针异常
        //以下是正常业务代码 省略
        return new ResultVo(500,null,arr);
    }

    @GetMapping("/test3")
    public ResultVo test3() {
        int i=10/0; //发生算术异常
        //以下是正常业务代码
        return new ResultVo(500,null,i);
    }

}
